using System;
using System.Collections;
using System.Collections.Generic;
using Entitas;
using UnityEngine;

public class DestroyCellSystem : ReactiveSystem<LogicEntity>
{
    LogicContext mContext;

    public DestroyCellSystem(LogicContext context) : base(context)
    {
        mContext = context;
    }

    protected override ICollector<LogicEntity> GetTrigger(IContext<LogicEntity> context)
    {
        return context.CreateCollector(LogicMatcher.DestroyCell.Added());
    }

    protected override bool Filter(LogicEntity entity)
    {
        return true;
    }

    protected override void Execute(List<LogicEntity> entities)
    {
        foreach (var e in entities)
        {
            LogicApi.DestroyCell(mContext, e);
            e.isDestroy = true;
        }
    }
}
